<!DOCTYPE html>
<html>
<head>
    <title>平涛</title>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="description" content="Write an awesome description for your new site here. You can edit this line in _config.yml. It will appear in your document head meta (for Google search results) and in your feed.xml site description.
">

    <link rel="stylesheet" type="text/css" href="__PUBLIC__/Wechat/lib/weui.min.css">
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/Wechat/css/jquery-weui.css">
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/Wechat/css/style.css">
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/Wechat/css/aui-iconfont.css">

    <style type="text/css">
        .weui_panel:after{border-bottom: none !important;  }
        .input_con{width: 88% !important;}
        .weui_cell_bd{margin:5px;}
        input{border: none}
        a{color: red}
        .weui_cell{padding: 0px !important;}
        input,textarea{background: #FAFAFA}
        .weui_cell:before{border-top: none !important;}
        .weui_navbar_item{padding: 17px 11px !important}
      
    </style>

</head>


<body ontouchstart>
    <form>
    <div class="weui_tab">
        <div class="weui_navbar weui_navbar1">
            <div class="weui_navbar_item">
                <div style="text-align:left;float:left">
                    <a href="{:U('Work/index')}">
                        <span class="aui-iconfont aui-icon-left"></span>
                    </a>
                </div>
                <span>工作总结</span>
                <div class="f-r">
                    <span class="f-s1" style="cursor:pointer;color:green;" onclick="tj()">修改</span>
                </div>
            </div>
        </div>

        <div class="weui_tab_bd">
            <div class="zj">
                <div class="weui_cell">
                    <div class="weui_cell_hd"><label for="time2" class="weui_label">总结日期：</label></div>
                    <div class="weui_cell_bd weui_cell_primary">{$workArr.date}</div>
                </div>
            </div>
            
            <div class="zj m-t1">
                <div class="weui_cell">
                    <div class="weui_cell_hd f-w1 "><label for="" class="weui_label">总结内容：</label></div>
                </div>
                
                <input type="hidden" name="id" value="{$workArr.id}" />  <!-- 存放当前总结id -->  
                <input type="hidden" name="num" id="num" value="{$workArr.content|count}" />  <!-- 存放内容行数量 -->

                <volist name="workArr.content" id="val">
                    <div class="weui_cell l-h2 input_box">
                        <div class="weui_cell_hd"><label for="" class="weui_label lab1">{$i}.</label></div>
                        <div class="weui_cell_bd weui_cell_primary">
                            <input type="hidden" name="conid{$i}" value="{$val.id}" />
                            <textarea class="weui_textarea textarea_1" name="content{$i}" rows="1">{$val.content}</textarea>
                        </div>
                    </div>
                </volist>
                
                <div class="text-cen">
                    <a href="#" onclick="add()" style="color:blue;">新增一行+</a>
                </div>
            </div>

        </div>
      
        <include file="Index/footer" />

    </div>
    </form>

    <script type="text/javascript" src="__PUBLIC__/Wechat/lib/jquery-2.1.4.js"></script>
    <script type="text/javascript" src="__PUBLIC__/Wechat/lib/fastclick.js"></script>
    <script type="text/javascript" src="__PUBLIC__/Wechat/js/autosize.js"></script>
    <script type="text/javascript" src="__PUBLIC__/Wechat/js/jquery-weui.js"></script>
    <script type="text/javascript" src="__PUBLIC__/layer/2.1/layer.js"></script> 
    <script>
        $(function() {
            FastClick.attach(document.body);
        });
        
        autosize(document.querySelectorAll('textarea'));

        // 添加新行
        function add(){
            var len = $('.input_box').length + 1;
            var content = '<div class="weui_cell l-h2 input_box"><div class="weui_cell_hd"><label for="" class="weui_label lab1">' + len + '.</label></div><div class="weui_cell_bd weui_cell_primary"><textarea class="weui_textarea textarea_1" name="content' + len + '" placeholder="请输入内容" rows="1"></textarea></div></div>';
            $('.input_box:last').after(content);
            $('#num').val(len);
        }

        // 保存
        function tj(){
            //$('form').submit();
            var con = 0; 
            for (var i = 0; i < $('.weui_textarea').length; ++i) {
                if($.trim($('.weui_textarea').eq(i).val()) !== ''){  // 如果此行内容不为空
                    con = 1;
                }
            }
            if(con == 1){  // 判断是否填写内容
                $.ajax({  
                    url: "{:U('Work/editCheck')}", 
                    type: "POST",  
                    data: $('form').serializeArray(), 
                    success: function(msg){  
                        console.log(msg);
                        if(msg['state'] == 200){
                            layer.msg(msg['content'],{icon:1,time:1000});
                            setTimeout('window.location.href = "{:U('Work/index')}"', 1000);
                        }else{
                            layer.msg(msg['content'],{icon:2,time:1000});
                        }
                    }  
                });
            }else{
                layer.msg('请填写总结内容',{icon:2,time:1000});
            }
            
             
        }
    </script>
</body>
</html>
